<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
<!--     <meta http-equiv="Cache-Control" content="no-siteapp" /> -->
    <title>首页</title>
   <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/js/easyui/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="/js/easyui/datagrid-detailview.js"></script>
    <script type="text/javascript" src="/js/petecat.js"></script>
     <script type="text/javascript" src="/js/jquery.cookie.js"></script>
    <link rel="stylesheet" type="text/css" href="/css/main.css"></link>
    <link rel="stylesheet" type="text/css" href="/css/themes/default/easyui.css"></link>
	<link rel="stylesheet" type="text/css" href="/css/themes/icon.css"></link>
	<link rel="stylesheet" type="text/css" href="/css/themes/color.css"></link>
    
</head>
<body  class="easyui-layout">
<div data-options="region:'north',border:false" class="indexBodyCls11" style="height: 80px;" >
	<div style="margin-right:20px;margin-top:10px;">
		<table width="100%" height="100%">
			<tr>
				<td rowspan="2">&nbsp;&nbsp;&nbsp;&nbsp;
				<font color="#222" style="font-family: Microsoft YaHei;color:lightgrey" size="6">规则引擎中心</font>
				</td>
				
				<td align="right">
				<font style="font-family: Microsoft YaHei;color:lightgrey"  size="2">
				             操作人员：<span id="opUserName"></span>
		         </td>
				</tr>
				<tr>
		        <td align="right">
					<a href="javascript:void(0)" id="logout" onclick="logout()" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon_logout'">
					<font  style="font-family: Microsoft YaHei;color:lightgrey">安全退出</font></a>&nbsp;&nbsp;&nbsp;&nbsp;
		        </td>
			</tr>			
		</table>
	</div>
</div>
<div  id="centerPanel" data-options="region:'center',border:false,iconCls:'icon-home'">
	<div id="tabs" class="easyui-tabs" data-options="border:false,fit:true" >  
	    <div title="系统菜单导航" id="menuDiv">
	   
	     </div>
		</div>

    </div>
   	<script type="text/javascript">
   	   if(window.top!=window.self){
   		   window.top.location.href='/index.html';
   	   }
    	var user = getSessionUser();
    	if(user == null){
    		window.location.href='/login.html';
    	}
    	$("#opUserName").text(user.userName);
    	//组装菜单
    	//获取权限
    	var powers = getUserPower();
    	if(powers !=null && powers.length>0){
    		for(var i=0;i<powers.length;i++){
    			var power = powers[i];
    			if(power.parentid=='TOP'){//顶级目录
    			   var html = $.trim(getTopMenuHtml(power,powers));
    			   if(html!=''){
    				 $("#menuDiv").append(html);
    			   }
    			}
    		}
    		$(".sys_menu").click(function(){
    			var href=$(this).attr("viewUrl");
    			var title=$(this).attr("title");
    			var code=$(this).attr("code");
    			var height =  document.body.clientHeight-115;
    			var src = href;
    			if(!$('#tabs').tabs('exists',title)){
    				$.messager.progress({text:'加载中...'});
    				timeoutintervalID = window.setTimeout(closeIndexLoading, 3000);
    				$('#tabs').tabs('add',{   
    				    title:title,
    				    cache:true,
    				    border:false,
    				    content:"<iframe  id='iframe"+code+"'  src='"+src+"' frameborder='0' scrolling='auto' height='"+height+"' width='100%'></iframe>",   
    				    closable:true
    				});
    				$('#tabs li').unbind('dblclick');
    				$('#tabs li').bind('dblclick',function(){
    					var tab = $('#tabs').tabs('getSelected');
    					if(tab.panel('options').closable){
    						var index = $('#tabs').tabs('getTabIndex',tab); 
    						$('#tabs').tabs('close',index);	
    					}
    				});
    			}else{
    					var tab = $("#tabs").tabs('getSelected');
    					var tabtitle = tab.panel('options').title;
    					if(tabtitle == title){
    						$.messager.show({
    							title:'提示',
    							msg:'处理页已经是当前页',
    							timeout:3000,
    							showType:'slide'
    						});
    					}else{
    						$('#tabs').tabs('select',title);
    					}
    				    $.messager.progress('close'); 
    			}
    		})
    	}
    	function logout(){
    		clearSession();
    		window.location.href='/login.html';
    	}
    	
    	function getTopMenuHtml(power,powers){
    		var html = "";
    		if(power.botflag=='0'
    				&& checkAddMenu(power,powers)){//是菜单并且有显示权限
    			  html+=' <div class="panel" style="display: block;">';
    			  html+=' <div class="panel-header panel-header-noborder">';
    			  html+='  <div class="panel-title">'+power.fundesc+'</div>';
    			  html+=' </div>';
    			  html+=' </div> ';
    			  html+='  <div style="margin-top:10px;margin-right:20px;margin-bottom:20px"> ';
    			  html+=getMenuHtml(power,powers);
    			  html+=' </div> ';
    		}
    		return html;
    	}
   
    	function getMenuHtml(power,powers){
    		var flag = false;
    	    var html='';
    	    for(var i=0;i<powers.length;i++){
    	    	var t = powers[i];
    	    	if(t.botflag=='0' 
    	    	    && t.parentid==power.funid
    				&& checkAddMenu(t,powers)){
        			flag = true;
        			html+='<button title="'+t.fundesc+'" code="'+t.funid+'" viewUrl="'+t.funpath+'"  style="width: 110px; height: auto;" class="sys_menu">';
        			html+='<div class="sys-ui-icon-big sys-ui-icon-idcard" style="margin:0 auto"></div>';
        			html+=' <div style="font-size: 14px;">'+t.fundesc+'</div>';
        			html+='</button>';
        		}
    	    }
    	    if(!flag){
    	    	html='';
    	    }
    	    return html;
    	}
    	
     
    	function checkAddMenu(power,powers){
    		var flag = false;
    		for(var i=0;i<powers.length;i++){
    			var t = powers[i];
    			if(power.funid==t.parentid){
					if(t.botflag=='1'){
						if(t.displayfun='1'){
							flag = true;
						}
					}else{
						flag = checkAddMenu(t,powers);
					}
    			}
    			if(flag){
    				break;
    			}
    		}
    		return flag;
    	}
    	


    	function closeIndexLoading(){
    		 $.messager.progress('close'); 
    	}
   	</script>
</body>
</html>